// JavaScript Document
$(document).ready(function(){
	$("#c_brand li:not(.style_1)").click(function(){
		//$(this).css({"color":"#fff","background":"#A5D610"})         
	    //   .siblings().css({"color":"#636363","background":"#FFFFFF"});
		$(this).attr('class','style_2');
		$(this).siblings().attr('class','others_style');
		$('#metadata_'+$(this).attr('parentid')).val($(this).attr('selfid'));
		formatFormData(1);
	});
	
	$("#pageNumberToJump").change(function(){
		if($('#pageNumberToJump').val() < 1)
		    $('#pageNumberToJump').val(1);
		if($('#pageNumberToJump').val() > $('#totalPage').val())
		    $('#pageNumberToJump').val($('#totalPage').val());
	});
});

function jampToCertanPage()
{
	formatFormData($('#pageNumberToJump').val());
}

function formatFormData(int_page){
	var str = '' + (window.location);
	var arr_url = str.split('/');
	var str_urlTitle = arr_url[5];
    var str_filter = '/' + str_urlTitle;
    
    var str_tmpFilter = '';
    if(int_page)
        str_tmpFilter += '/page/' + int_page;
    //获取filter
    $("#filterListForm li[class='style_2'][selfid!='0']").each(function(){
        str_tmpFilter += '/' + this.getAttribute('parentid') + '/' + this.getAttribute('selfid');
    });
    //获取sort
    if($('#sortby_price_select').get()[0]){
        if($('#sortby_price_select').val()!='0'){
            str_tmpFilter += '/price/' + $('#sortby_price_select').val();
        }else if($('#sortby_created_select').val()!='0'){
            str_tmpFilter += '/created/' + $('#sortby_created_select').val();
        }
    }
    
    str_filter += str_tmpFilter;
    
    arr_url = arr_url.slice(0, 6);
    
    $.ajax({
        type: 'post',
        url: '/a/categoryindex' + str_filter,
        dataType: "html",
        async: false,  //false is synchronization , true is asynchronism
        success: function(data){
            $('#RightBlockFreshContent').replaceWith(data);
            //window.location = arr_url.join("/") + str_tmpFilter;
            return true;
        },
        error: function(){
            result = false;
        }
    });
}

$(function(){
	$(".list_title img").toggle(
	function(){
		$(this).parents(".list_title").find("p").hide();
		var src = "//i.akimimi.com/t/default_zh_cn/image/p1_leftMenuPlus.gif";
		$(this).attr("src",src);
	},
	function(){
		$(this).parents(".list_title").find("p").show();
	    var src = "//i.akimimi.com/t/default_zh_cn/image/p1_leftMenuMinus.gif";
		$(this).attr("src",src);
    });

    $("div.list_title p:not(.t_1)").hover(
	    function(){
	        $(this).css({"background":"#F7F7F7","color":"#5DAF27","cursor":"pointer"});
	        },
	    function(){
		    $(this).css({"background":"#F7F7F7","color":"#666666"});
    });


    /*$("#c_brand li:not(.style_1)").click(function(){					   
	    $(this).css({"color":"#fff","background":"#A5D610"})         
	       .siblings().css({"color":"#636363","background":"#FFFFFF"});  
    });*/

    $(".right_nva_px li").mouseover(function(){
	    $(this).css('background','#eee');
	}).mouseout(function(){
	    $(this).css('background','#fff');
    }).click(function(){
	    $(".right_nva_px span").html($(this).html());
	    $(".right_nva_px ul").hide();
	});

    $(".right_nva_px span").click(function(){
	    $(".right_nva_px ul").css("display") == 'none' ? $(".right_nva_px ul").show() : $(".right_nva_px ul").hide();
    });

    $(".right_nva_shi li").mouseover(function(){
	    $(this).css('background','#eee');
    }).mouseout(function(){
	    $(this).css('background','#fff');
    }).click(function(){
	    $(".right_nva_shi span").html($(this).html());
	    $(".right_nva_shi ul").hide();
    });

    $(".right_nva_shi span").click(function(){
	    $(".right_nva_shi ul").css("display") == 'none' ? $(".right_nva_shi ul").show():$(".right_nva_shi ul").hide();
    });

    //鼠标经过商品样式
    /*$('.product img').hover(
        function(){
	        $(this).css({"border":"solid #55A01E 1px","cursor":"pointer"});
	    },
	    function(){
	    	$(this).css({"border":"solid #E5E5E5 1px"});
	    });*/
});